<script src="<?php echo base_url();?>js/avatar_maker.js?<?php echo time(); ?>" type="text/javascript"></script>
<div id="participate-index">
  <?php
    if (validation_errors()) {
      $part_1_style = 'display:none';
      $part_2_style = '';
    }
    else {
      $part_2_style = 'display:none';
      $part_1_style = '';
    }
  ?>
  <!--
  <div id="home-participate-button"><?php echo anchor('tab', "Начало"); ?></div>
  <div id="gallery-participate-button"><?php echo anchor('gallery', "Галерия"); ?></div>
   -->
  <?php echo form_open('participate/'); ?>
  <div id="form-part-1" style="<?php echo $part_1_style; ?>">
    <div class="avatar-creator-area">
      <div id="avatar-styles">
        <div id="avatar-styles-container">
          <?php for ($i = 1; $i <= $body_parts['styles']; $i++) :?>
          <div class="avatar-style" id="style-<?php echo $i; ?>">
            <img alt="" src="<?php echo base_url(); ?>images/avatars/styles/styles_<?php echo $i; ?>.png" />
          </div>
          <?php endfor; ?>
          <div class="clear-both"></div>
        </div>
      </div>
      <?php
      // just to make it shorter for later use
      $style_id = $form_fields['images']['body_style'];
      $default_class = $style_id ? "" : "avatar-hidden";
      ?>
      <?php foreach ($body_parts as $key => $value) : ?>
      <?php if ($key != 'styles' && $key != 'tribune') : ?>
      <div class="avatar-parts-section" id="avatar-<?php echo $key; ?>" style="display: none;">
        <h3 onclick="show_items('<?php echo $key; ?>')"><?php echo $this->lang->line('avatar_' . $key . '_label'); ?></h3>
        <div id="avatar-<?php echo $key; ?>-items" class="avatar-items" style="display:none">
          <?php for ($i = 1; $i <= $body_parts[$key]; $i++) :?>
          <div class="avatar-<?php echo $key; ?>-tmb" id="<?php echo $key; ?>-style-<?php echo $i; ?>" rel="<?php echo $i; ?>">
            <?php if ($key == 'back') : ?>
            <img id="avatar-<?php echo $key; ?>-tmb-<?php echo $i; ?>" alt="" src="<?php echo base_url()?>images/avatars/<?php echo $key; ?>/<?php echo $key; ?>_<?php echo $i; ?>_tmb.png" />
            <?php else :?>
            <img id="avatar-<?php echo $key; ?>-tmb-<?php echo $i; ?>" alt="" src="<?php echo base_url()?>images/avatars/<?php echo $key; ?>/<?php echo $key; ?>_<?php echo $style_id ? $style_id : '1'; ?>_<?php echo $i; ?>_tmb.png" />
            <?php endif;?>
          </div>
          <?php endfor; ?>
          <div class="clear-both"></div>
        </div>
      </div>
      <?php endif; ?>
      <?php endforeach; ?>

      <div class="avatar-wrapper">
        <?php if (!$form_fields['images']['body_style']) : ?>
        <div class="avatar" id="default-avatar">
          <img alt="Изберете стил" src="<?php echo base_url()?>images/avatars/styles/styles_0.png" />
        </div>
        <?php endif; ?>
        <div class="avatar" style="display:none" id="custom-avatar">
          <?php foreach ($body_parts as $key => $value) : ?>
          <?php if ($key == 'back') : ?>
          <div id="avatar-piece-back"><img src="<?php echo base_url()?>images/avatars/<?php echo $key; ?>/<?php echo $key; ?>_<?php echo $form_fields['images'][$key.'_img']; ?>.png" /></div>
          <?php elseif ($key != 'styles') : ?>
          <div class="avatar-piece" id="avatar-piece-<?php echo $key; ?>" ><img src="<?php echo base_url()?>images/avatars/<?php echo $key; ?>/<?php echo $key; ?>_<?php echo $style_id ? $style_id : '1'; ?>_<?php echo $form_fields['images'][$key.'_img']; ?>.png" /></div>
          <?php endif; ?>
          <?php endforeach; ?>
        </div>
      </div>
    </div>
    <div id="to-part-2-link" style="display:none">Напред</div>
  </div>
  <div id="form-part-2" style="<?php echo $part_2_style; ?>">
    <div class="left-page">
      <div class="form-element">
      <?php echo form_error('name'); ?>
      <?php echo form_label($this->lang->line('form_first_name_label'), 'first_name'); ?>
      <?php echo form_input($form_fields['first_name']);?>
      </div>
      <div class="form-element">
      <?php echo form_label($this->lang->line('form_last_name_label'), 'last_name'); ?>
      <?php echo form_input($form_fields['last_name']);?>
      </div>
      <div class="form-element">
      <?php echo form_label($this->lang->line('form_email_label'), 'email'); ?>
      <?php echo form_input($form_fields['email']);?>
      </div>
      <div class="form-element align_left">
      <?php echo form_checkbox($form_fields['agree_years']);?>
      <?php echo form_label($this->lang->line('agree_years_text'), 'agree_years'); ?>
      </div>
      <div class="form-element align_left">
      <?php echo form_checkbox($form_fields['agree_tos']);?>
      <?php echo form_label($this->lang->line('agree_tos_text'), 'agree_tos'); ?>
      </div>
      <div id="error-message-container">
        <?php echo validation_errors(); ?>
      </div>
    </div>
    <div class="right-page">
      В интернет имам право да:
      <div class="form-element">
      <?php echo form_dropdown('first_part_sentence',$form_fields['first_part_sentence'], array('', $this->input->post('first_part_sentence')), 'id=first_part_sentence');?>
      </div>
      ... ако/доколкото...
      <div class="form-element">
      <?php echo form_textarea($form_fields['personal_message']);?>
      </div>
      <span>[макс. 140 знака]</span><br />
      <span id="personal_message_example">Пример: Имам право да ям круши, ако/доколкото не съм ги откраднал от съседа</span><br />
      <div id="form-navigation">
        <div id="to-part-1-link">Обратно</div>
        <div class="form-element">
        <?php echo form_submit('form_submit', 'Участвай'); ?>
        </div>
      </div>
    </div>
    <?php echo form_hidden($form_fields['images']); ?>
  </div>
  <?php echo form_close(); ?>
</div>